﻿using System;
using System.Windows.Automation;

namespace QuickUIT.Controls
{
    /// <summary>
    /// Represents a check box control.  
    /// </summary>
    public class UICheckBox : UIBaseControl
    {
        /// <summary>
        /// Gets the current toggle state of the control.
        /// If the control does not support the <see cref="ToggleState"/> , a null reference is returned.
        /// </summary>
        public new ToggleState? ToggleState
        {
            get { return base.ToggleState; }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UICheckBox"/> class. 
        /// </summary>
        public UICheckBox() : base(ControlType.CheckBox)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UICheckBox"/> class.
        /// </summary>
        /// <param name="parent">The parent of this control.</param>
        public UICheckBox(UIBaseControl parent) : base(parent, ControlType.CheckBox)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UICheckBox"/> class.
        /// </summary>
        /// <param name="locator">The locator used to find the specific control.</param>
        public UICheckBox(string locator) : base(null, ControlType.CheckBox, locator)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UICheckBox"/> class.
        /// </summary>
        /// <param name="parent">The parent of this control.</param>
        /// <param name="locator">The locator used to find the specific control.</param>
        public UICheckBox(UIBaseControl parent, string locator) : base(parent, ControlType.CheckBox, locator)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UICheckBox"/> class.
        /// </summary>
        /// <param name="control">The underlying <see cref="AutomationElement"/> of the control.</param>
        public UICheckBox(AutomationElement control) : base(control, ControlType.CheckBox)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UICheckBox"/> class.
        /// </summary>
        /// <param name="parent">The parent of the control</param>
        /// <param name="control">The underlying <see cref="AutomationElement"/> of the control.</param>
        public UICheckBox(UIBaseControl parent, AutomationElement control) : base(parent, control, ControlType.CheckBox)
        {
        }

        /// <summary>
        /// Toggles the state of the checkbox. 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        /// <remarks>A control will cycle through its <see cref="ToggleState"/> in this order: On, Off and, if supported, Indeterminate.</remarks>
        public new void Toggle()
        {
            base.Toggle();
        }

        /// <summary>
        /// Toggles the checkbox on. 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new void ToggleOn()
        {
            base.ToggleOn();
        }

        /// <summary>
        /// Toggles the checkbox off. 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new void ToggleOff()
        {
            base.ToggleOff(); 
        }
    }
}
